package org.wx.ormtest.step01.help;


import java.sql.ResultSet;
import java.sql.SQLException;

import lombok.extern.slf4j.Slf4j;
import org.wx.ormtest.step00.entity.User;

/**
 * @description: 结果集映射帮助类
 * @author: wangxun
 * @createDate: 2021/3/2
 * @version: 1.0
 */
@Slf4j
public class UserEntityHelper {
    static public User create(ResultSet rs){
        if(null == rs){
            return null;
        }
        try {
            int userId = rs.getInt(1);
            String userName = rs.getString(2);
            String password = rs.getString(3);
            User user = new User();
            user.setUserId(userId);
            user.setUserName(userName);
            user.setPassword(password);
            //log.info("用户信息:{}",user);
            return user;

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }
}
